package slu.appli.wodtimer.stringparser;

import slu.appli.tools.parser.stringparser.StringParserException;
import slu.appli.tools.parser.stringparser.impl.AbstractEscapeChar;
import slu.appli.tools.parser.stringparser.interfaces.model.ModelBuilderInterface;

public class EscapeCharOpenGroup 
extends AbstractEscapeChar {

	public EscapeCharOpenGroup() {
		super('(',"openGroup");
	}

	@Override
	public void processPreviousString(final String value, final ModelBuilderInterface modelBuilder) {
		int occurs = 1;
		if (value != null) {
			occurs = Integer.parseInt(value);
			if (occurs < 1) {
				throw new StringParserException("nombre d'occurrence invalide : " + occurs);
			}
		}
		modelBuilder.openGroup(occurs);
	}

	@Override
	public void processNextString(final String value, final ModelBuilderInterface modelBuilder) {
	}

}
